/**
 * author wen
 * cunyu
 * email wjd_13@hotmail.com
 */
package com.cunyu.service;

import com.cunyu.bean.Form;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * banner 表操作
 * @author win
 * 2019/04/25-17:35
 */
@Service
public class BannerService extends BaseService {

    public List<Map<String, Object>> banners(){
        String sql = "select * from banner order by id " ;

        return getList(sql) ;
    }

    public Map<String, Object> getBanner(int id) {
        String sql = "select * from banner where id = ?" ;
        return getMap(sql,id) ;
    }

    public int newBanner(Form form) {
        String sql = "insert into banner (img,type,url,des,state)" +
                " values (?,?,?,?,?)" ;
        return insert(sql,form.getImg(),intV(form.getType()),form.getUrl(),form.getDes(),
                intV(form.getState())) ;
    }

    public void updateBanner(Form form) {
        String sql = "update banner set img=?,type=?,url=?,des=?,state=? where id = ?" ;
        exec(sql,form.getImg(),intV(form.getType()),form.getUrl(),form.getDes(),
                intV(form.getState()),intV(form.getId())) ;
    }
}
